package com.zhuojy.equity.mall.admin.web.controller.tExpenseAccount;

import com.zhuojy.equity.mall.admin.common.entity.TAuditCenter;
import com.zhuojy.equity.mall.admin.common.entity.po.TExpenseAccountPO;
import com.zhuojy.equity.mall.admin.common.pojo.JsonResult;
import com.zhuojy.equity.mall.admin.service.tExpenseAccount.TExpenseAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:LYL
 * @Date 2024/3/31 19:35
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("ExpenseAccount")
@Api(tags = "报销/借款模块")
public class TExpenseAccountController {
    @Autowired
    private TExpenseAccountService tExpenseAccountService;

    @ApiOperation(value = "报销借款列表，分页查询", httpMethod = "POST", notes = "报销借款列表分页查询")
    @RequestMapping("findExpenseAccountFenYe")
    public JsonResult findExpenseAccountFenYe(@RequestBody TExpenseAccountPO tExpenseAccountPO, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return tExpenseAccountService.findExpenseAccountFenYe(tExpenseAccountPO, pageNum, pageSize);
    }

    @ApiOperation(value = "报销借款列表回显", httpMethod = "POST", notes = "报销借款列表分页回显")
    @RequestMapping("findExpenseAccountById")
    public TExpenseAccountPO findExpenseAccountById(Long id){
        return tExpenseAccountService.findExpenseAccountById(id);
    }

    @ApiOperation(value = "报销借款列表修改状态，修改状态", httpMethod = "POST", notes = "报销借款列表修改状态")
    @RequestMapping("updateExpenseAccountStatus")
    public JsonResult updateExpenseAccountStatus(@RequestBody TExpenseAccountPO tExpenseAccountPO) {
        try {
            tExpenseAccountService.updateExpenseAccountStatus(tExpenseAccountPO);
            return JsonResult.success(200, "修改成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444, "修改失败！");
        }
    }

    @ApiOperation(value = "报销借款添加", httpMethod = "POST", notes = "报销借款添加")
    @RequestMapping("addExpenseAccount")
    public JsonResult addExpenseAccount(@RequestBody TExpenseAccountPO tExpenseAccountPO) {
        try {
            tExpenseAccountService.addExpenseAccount(tExpenseAccountPO);
            return JsonResult.success(200, "添加成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444, "添加失败！");
        }
    }

}
